﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace Jermaine.Encrypt
{
    public class GenericEncrypt
    {
        private GenericEncrypt() { }

        /// <summary>
        /// Md5
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static String Md5(string text) {
            using (var md5 = new MD5CryptoServiceProvider()) {
                var textBytes = md5.ComputeHash(Encoding.Default.GetBytes(text));
                return Convert.ToBase64String(textBytes);
            }
        }

        /// <summary>
        /// Sha1
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static String Sha1(string text) {
            using (var sha1 = new SHA1CryptoServiceProvider()) {
                var textBytes = sha1.ComputeHash(Encoding.Default.GetBytes(text));
                return Convert.ToBase64String(textBytes);
            }
        }


    }
}
